package cn.kdlc.demo.recycler.adapter;

import android.support.annotation.NonNull;
import android.view.View;
import android.widget.FrameLayout;
import cn.kdlc.demo.recycler.databinding.HeaderBinding;
import cn.kdlc.demo.recycler.databinding.ItemBinding;
import cn.kdlc.demo.recycler.model.Header;
import cn.kdlc.demo.recycler.model.User;
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractDraggableItemViewHolder;

/**
 * Created by android on 2015/11/26 0026.
 */
public class UserHolder extends AbstractDraggableItemViewHolder {

    private ItemBinding itemBinding;

    private HeaderBinding headerBinding;

    public View dragHandler;

    public FrameLayout container;

    public UserHolder(View view, int viewType) {
        super(view);
        switch (viewType) {
            case UserAdapter.VIEW_TYPE_HEADER:
                headerBinding = HeaderBinding.bind(view);
                break;
            case UserAdapter.VIEW_TYPE_ITEM:
                itemBinding = ItemBinding.bind(view);
                dragHandler = itemBinding.dragHandler;
                container = itemBinding.container;
                break;
            default:
                throw new RuntimeException("no such view type");
        }
    }

    public void bind(@NonNull User user) {
        itemBinding.setItem(user);
    }

    public void bind(@NonNull Header header) {
        headerBinding.setHeader(header);
    }
}
